package org.wu.framework.authorization.platform.application.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.wu.framework.authorization.platform.application.SysDictionaryApplication;
import org.wu.framework.authorization.platform.application.assembler.SysDictionaryDTOAssembler;
import org.wu.framework.authorization.platform.application.command.SysDictionaryCommand;
import org.wu.framework.authorization.platform.domain.model.sys.dictionary.SysDictionary;
import org.wu.framework.authorization.platform.domain.model.sys.dictionary.SysDictionaryRepository;
import org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;

/**
 * describe
 *
 * @author Jia wei Wu
 * @date 2023/05/17 11:19 晚上
 * @see DefaultDDDLazyApplicationImpl
 **/
@LazyApplication
public class SysDictionaryApplicationImpl implements SysDictionaryApplication {

    @Autowired
    SysDictionaryRepository sysDictionaryRepository;

    /**
     * describe 新增
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> save(SysDictionaryCommand sysDictionaryCommand) {
        SysDictionary sysDictionary = SysDictionaryDTOAssembler.toDictionary(sysDictionaryCommand);
        return sysDictionaryRepository.story(sysDictionary);
    }

    /**
     * describe 更新
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> update(SysDictionaryCommand sysDictionaryCommand) {
        SysDictionary sysDictionary = SysDictionaryDTOAssembler.toDictionary(sysDictionaryCommand);
        return sysDictionaryRepository.story(sysDictionary);
    }

    /**
     * describe 查询单个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> findOne(SysDictionaryCommand sysDictionaryCommand) {
        SysDictionary sysDictionary = SysDictionaryDTOAssembler.toDictionary(sysDictionaryCommand);
        return sysDictionaryRepository.findOne(sysDictionary);
    }

    /**
     * describe 查询多个
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<List<SysDictionary>> findList(SysDictionaryCommand sysDictionaryCommand) {
        SysDictionary sysDictionary = SysDictionaryDTOAssembler.toDictionary(sysDictionaryCommand);
        return sysDictionaryRepository.findList(sysDictionary);
    }

    /**
     * describe 删除
     *
     * @param
     * @return
     * @exception/throws
     * @author Jia wei Wu
     * @date 2023/05/17 11:19 晚上
     **/

    @Override
    public Result<SysDictionary> delete(SysDictionaryCommand sysDictionaryCommand) {
        SysDictionary sysDictionary = SysDictionaryDTOAssembler.toDictionary(sysDictionaryCommand);
        return sysDictionaryRepository.delete(sysDictionary);
    }

}